package com.desire.bean.sys;

import com.desire.common.validation.group.Login;
import com.desire.common.validation.group.Modify;
import com.desire.common.validation.group.Save;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @author LittleDesire
 * @description
 * @date 2022-05-07 周六 15:53
 * @since 17
 */
@Data
@ApiModel(value = "用户实体", description = "用户的数据")
public class User {
    @ApiModelProperty(value = "账号", notes = "用户名", required = true)
    @NotBlank(message = "姓名不能为空", groups = {Save.class, Modify.class, Login.class})
    String name;

    @NotNull(message = "密码不能为空", groups = {Save.class})
    @Pattern(regexp = "\\w{3,6}", message = "密码必须是3-6位",groups = {Save.class})
    @ApiModelProperty(value = "密码", notes = "登录密码", required = true)
    @NotBlank(message = "请输入密码", groups = {Login.class})
    String password;

    @ApiModelProperty(value = "年龄", notes = "用户年龄")
    @Min(value = 12, message = "年龄至少为12岁", groups = {Save.class})
    int age;
}
